<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(t => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.blocklist);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [blocklist_test_service_uuid]}],
        optionalServices: [generic_access.name]
    })
    .then(device => device.gatt.connect())
    .then(gattServer => gattServer.getPrimaryService(generic_access.name))
    .then(service => service.getCharacteristic(peripherial_privacy_flag.name))
    .then(characteristic => {
        return characteristic.readValue()
        .then(() => promise_rejects_dom(t, 'SecurityError', characteristic.writeValue(new Uint8Array(1))));
    });
}, 'Characteristic with exclude-writes fullfills read and rejects write.');
</script>
